package main;
import java.sql.Array;
import java.util.*;

import Bean.UserInfoBean;
import utils.DBUtils;

public class Admin {
    static UserInfoBean staticuser;
    static DBUtils dbUtils;
    static Scanner sc = new Scanner(System.in);
    public static void mainScreen(UserInfoBean user){
        staticuser=user;
        System.out.println("---------这里是管理员界面---------");
        System.out.println("欢迎 管理员 （ " + user.getName() +" ) ~~~~~~~~~~~  您的账户有 :" + user.getAsset() + "    ########### 银行卡号是：" +user.getBankCard());

        userBreak: while(true) {
            System.out.println("请选择你要做什么:");
            System.out.println("1 - 显示所有用户 ");
            System.out.println("2 - 管理用户 ");
            System.out.println("3 - 退出登录 ") ;
            switch (sc.nextInt()) {
                case 1:
                    userList();
                    break userBreak;
                case 2:
                    AdminMange.manageUser(user);
                    break userBreak;
                case 3:
                    new Open().start();
                    break;
                default:
                    System.out.println("不要胡乱输入哦！！！");
                    break;
            }
        }
    }
    public static void userList() {
        System.out.println("ID\t姓名\t\t\t银行卡号\t\t\t资产");
        List<UserInfoBean> userlist = new ArrayList<>();
        userlist=dbUtils.selectUsers();
        for(UserInfoBean user : userlist){
            System.out.println(user.getID()+"\t"+user.getName()+"\t"+user.getBankCard()+"\t"+user.getAsset());
        }
        System.out.println("\n");
        System.out.println("\n按任意键返回！！！");
        sc.nextLine();
        sc.nextLine();
        mainScreen(staticuser);
    }


}


